﻿using System;

namespace Is
{
    public static class IsStringFluentExtensions
    {
        public static bool Contains(this IIs<string> iser, string expectedSubstring)
        {
            return iser.Apply(
                t => Core.Is.Contains(t, expectedSubstring),
                t => Core.Is.NotContains(t, expectedSubstring));
        }

        public static bool StartsWith(this IIs<string> iser, string expectedSubstring)
        {
            return iser.Apply(
                t => Core.Is.StartsWith(t, expectedSubstring),
                t => !Core.Is.StartsWith(t, expectedSubstring));
        }

        public static bool EndsWith(this IIs<string> iser, string expectedSubstring)
        {
            return iser.Apply(
                t => Core.Is.EndsWith(t, expectedSubstring),
                t => !Core.Is.EndsWith(t, expectedSubstring));
        }

        public static bool Empty(this IIs<string> iser)
        {
            if (iser.Target == null) throw new ArgumentNullException("actualString");
            return iser.Apply(
                t => Core.Is.Equal(t, string.Empty),
                t => Core.Is.NotEqual(t, string.Empty));
        }

        public static bool NullOrEmpty(this IIs<string> iser)
        {
            return iser.Apply(
                string.IsNullOrEmpty,
                t => !string.IsNullOrEmpty(t));
        }

        public static bool NullOrWhiteSpace(this IIs<string> iser)
        {
            return iser.Apply(
                string.IsNullOrWhiteSpace,
                t => !string.IsNullOrWhiteSpace(t));
        }

    }
}